package com.java.zhuiyun.api.carousel.mapper;

import com.java.zhuiyun.api.carousel.entity.Carousel;
import com.java.zhuiyun.common.mapper.BaseMapper;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import com.java.zhuiyun.util.pageUtil.PageResult;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @InterfaceName CarouselMapper
 * @Description TODO
 * @Author wuwan
 * @Date 2023/8/15 16:19
 **/
@Mapper
public interface CarouselMapper extends BaseMapper<Carousel> {
    /*
    * @Author wuwan
    * @Description todo 轮播图信息查询
    * @Date 2023/8/15 21:04
    * @Return
    * @param null
    */
    @Select("SELECT * FROM carousel WHERE del_flag = 0  ORDER BY sort_number ASC,update_time DESC ,create_time DESC ")
    List<Carousel> getCarousel(PageRequest pageRequest);
    /*
    * @Author wuwan
    * @Description todo 轮播图添加
    * @Date 2023/8/15 21:04
    * @Return
    * @param null
    */
    @Insert("insert into carousel (carousel_name,img,sort_number,create_time,update_time,del_flag,carousel_status) values (#{carouselName},#{img},#{sortNumber},#{createTime},#{updateTime},0,#{carouselStatus});")
    Integer addCarousel(Carousel carousel);
    /*
    * @Author wuwan
    * @Description todo 轮播图信息修改
    * @Date 2023/8/16 16:12
    * @Return
    * @param null
    */
    @Update("update carousel set carousel_name = #{carouselName},img=#{img},sort_number=#{sortNumber},update_time=#{updateTime}  where id = #{id};")
    Integer updateCarousel(Carousel carousel);
    /*
     * @Author wuwan
     * @Description todo 轮播图信息修改
     * @Date 2023/8/16 16:12
     * @Return
     * @param null
     */
    @Update("update carousel set carousel_name = #{carouselName},sort_number=#{sortNumber},update_time=#{updateTime}  where id = #{id};")
    Integer updateData(Carousel carousel);

    /*
    * @Author wuwan
    * @Description todo 轮播图启用方法
    * @Date 2023/8/16 16:05
    * @Return
    * @param null
    */
    @Update("update carousel set  carousel_status = #{carouselStatus} where id=#{id}")
    Integer ReleaseCarousel(Integer id,Integer carouselStatus);
    /*
    * @Author wuwan
    * @Description todo 轮播图删除方法
    * @Date 2023/8/16 16:05
    * @Return
    * @param null
    */
    @Update("update carousel set  del_flag = 1 where del_flag =0 and id=#{id}")
    Integer deleteData(Integer id);

}
